package 集合.双列.Map.HashMap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

public class test {
    public static void main(String[] args) {

        String[] arr={"A","B","C","D"};//通过数字来判断

        ArrayList<String> list=new ArrayList<>();
        Random random=new Random();

        for (int i = 0; i < 80; i++) {
            int index=random.nextInt(arr.length);
            System.out.println(arr[index]);
            list.add(arr[index]);//里面全是ABCD
        }


        HashMap<String,Integer> hashMap=new HashMap<>();//里面是ABCD和次数
        for (String name : list) {
            if(hashMap.containsKey(name)){
                int count=hashMap.get(name);
                count++;
                hashMap.put(name,count);

            }
            else {
                hashMap.put(name,1);
            }

        }
        System.out.println(hashMap);

    }
}
